package com.xzh.controller;

import com.xzh.common.Result;
import com.xzh.entity.Users;
import com.xzh.service.UsersService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class WebController {

    @Resource
    private UsersService usersService;

    //登录获取用户数据
    @PostMapping("/login")
    public Result login(@RequestBody Users users){
        Users dpusers = usersService.login(users);
        return Result.success(dpusers);
    }

    //注册上传用户数据
    @PostMapping("/register")
    public Result register(@RequestBody Users users){
        usersService.register(users);
        return Result.success();
    }

    @PutMapping("/Home/person")
    public Result updatePerson(@RequestBody Users users){
        usersService.updatePerson(users);
        return Result.success();
    }

    @GetMapping("/Home/CarInformation")
    public Result getUserInfo(@RequestParam int userId){
        Users dpusers =usersService.getUser(userId);
        return Result.success(dpusers);
    }
}
